import Vue from 'vue'
import Vuex from 'vuex'
import App from './App'
import router from './router'
import getStoreData from './store'
import WebSocketPlugin from './plugins/websocket'

Vue.config.productionTip = false

Vue.use(Vuex)
Vue.use(WebSocketPlugin)

Vue.socket.connect('ws://wildhorse.com:8080')

const Store = Vuex.Store
const store = new Store(getStoreData())

/* eslint-disable no-new */
const v = new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})

window.Vue = Vue

Vue.reset = function () {
  const n = new Store(getStoreData())
  v.$store.replaceState(n.state)
}
